<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 获取7天后的时间
        function getDate(n) {
            const date = new Date()
            const year = date.getFullYear()
            const month = date.getMonth() + 1
            const day = date.getDate() + n
            const localTime = date.toLocaleTimeString()
            console.log("现在是" + year + "年" + month + "月" + day + "日" + localTime);
        }
        getDate(7)

        //用reduce方法：
        // 统计字符串中出现次数最多的，并打印次数
        const str = "hfoawhuopajpgajwiahfjapowghiawj"
        // console.log(str.split(''));
        const countStr = str.split('').reduce((p, c) => {
            // console.log(p, c);
            (c in p) ? (p[c]++) : (p[c] = 1)
            return p
        }, {})
        console.log(countStr);

        //切割地址的查询字符串
        const str2 = "http://www.baidu.com?a=1&b=2&c=3"
        const urlStr = str2.split("?")[1].split("&").reduce((prev, current) => {
            const itemArray = current.split("=")
            console.log(itemArray);
            for(let key in itemArray){
                console.log(key);
            }

        }, {})
        console.log(urlStr);
    </script>
</body>

</html>